package com.ruoyi.tactics.algorithm;

import com.ruoyi.common.utils.ZodiacCalculator;
import com.ruoyi.tactics.ZodiacResult;

import java.util.*;

public class FourZodiacAlgorithm extends AbstractAlgorithm {
    @Override
    public Boolean isWin(ZodiacResult zodiacResult, String... code) {
        Integer num = 0;
        ZodiacCalculator zodiacCalculator = new ZodiacCalculator();
        Set<String> zodiacs = new HashSet<>();
        zodiacResult.getPm().forEach(r -> {
            zodiacs.add(zodiacCalculator.getZodiacByAge(r));
        });
        Set<String> codes = new HashSet<>();
        codes.addAll(Arrays.asList(code));
        for (String zodiac : code) {
            num += zodiacs.contains(zodiac)?1:0;
        }
        return num == 4;
    }


    public static void main(String[] args) {
        FourZodiacAlgorithm algorithm = new FourZodiacAlgorithm();
        ZodiacResult zodiacResult = new ZodiacResult();
        zodiacResult.setPm(Arrays.asList(1,2,3,4,49));
        System.out.println( algorithm.isWin(zodiacResult,"蛇","龙","兔","虎"));
        System.out.println( algorithm.isWin(zodiacResult,"猪","蛇","兔","虎"));


    }
}
